package com.hogan.hoganproject.video;

import android.os.Bundle;
import android.widget.TextView;

import com.hogan.hoganproject.R;
import com.hogan.hoganproject.base.fragment.BaseFragment;
import com.hogan.hoganproject.video.mvp.VideoControl;
import com.hogan.hoganproject.video.mvp.VideoPresenter;

/**
 * Author: chenhu
 * Time: 2020/8/28 16:03
 * Description do somethings
 */
public class VideoFragment extends BaseFragment<VideoPresenter> implements VideoControl.VideoView {
    TextView mTextView;

    public static VideoFragment newInstance() {
        Bundle args = new Bundle();
        VideoFragment fragment = new VideoFragment();
        fragment.setArguments(args);
        return fragment;
    }

    @Override
    public int getLayoutResID() {
        return R.layout.second_fragment;
    }

    @Override
    protected VideoPresenter initPresenter() {
        mFragmentPresenter = new VideoPresenter();
        mFragmentPresenter.onAttack(this);
        return mFragmentPresenter;
    }

    @Override
    protected void initView() {
        mTextView = mBaseView.findViewById(R.id.second_textview);
        mFragmentPresenter.setName();
    }

    @Override
    public void onUnsubscribe() {
        if (mFragmentPresenter != null) {
            mFragmentPresenter.onDetach();
        }
    }

    @Override
    public void onRecoverLoadData() {
        //要再次onAttack，不然view为null
        mFragmentPresenter.onAttack(this);
        if (mFragmentPresenter != null) {
            mFragmentPresenter.setResetName();
        }
    }

    @Override
    public void setName(String name) {
        mTextView.setText(name);
    }

    @Override
    public void showDialog() {
        mLoadingDialog.show();
    }

    @Override
    public void disDialog() {
        mLoadingDialog.dismiss();
    }

}
